﻿
CREATE FUNCTION dbo._CreateOrAlter
( @ObjectName sysname,
	@ObjectText varchar(8000)
)RETURNS varchar(8000)
AS
BEGIN

IF dbo._ObjectExists(@ObjectName) = 0 RETURN @ObjectText

DECLARE @I int

SET @I = PATINDEX('CREATE',@ObjectText)

RETURN 'ALTER'+SUBSTRING(@ObjectText,@i+7,8000)

END

